import React, { Component } from 'react'
import Axios from 'axios'
import Com from '../../components/List'
import TOP from '../../components/TOP'
class View extends Component {
  constructor(props) {
    super(props)
    this.state = {
      list: [],
    }
  }
  addapi(page = 1) {
    Axios.get('api/feeds', { page: page }).then((res) => {
      // console.log(res.data.data)
      if (res.data.data.count === 200) {
        this.setState({
          ...this.state,
          list: res.data.data.feeds,
        })
      }
    })
  }
  componentDidMount() {
    this.addapi()
  }
  render() {
    let { list } = this.state
    return (
      <div className="home clear">
        <div className="list left">
          <div>
            {list.map((res) => {
              return <Com key={res.id} obj={res} />
            })}
          </div>
          <div className="listBot">
            <a href="/not">获取更多热榜内容</a>
          </div>
        </div>
        <div className="right-list right">
          <TOP />
        </div>
      </div>
    )
  }
}
export default View
